#ifndef FORMULAFACTORYUTIL_H_INCLUDED
#define FORMULAFACTORYUTIL_H_INCLUDED

#include "formulaelement.h"
#include "../realnumber/realnumber.h"
#include "../realnumber/operations/realvariable.h"
#include "../realnumber/operations/realplus.h"
#include "../realnumber/operations/realminus.h"
#include "../realnumber/operations/realmultiplication.h"
#include "../realnumber/operations/realdivide.h"
#include "../realnumber/operations/realpow.h"

class FormulaFactoryUtil {
    private:
        static inline FormulaElement& getRealRandomNumber(int shift, int minus) {
            return *(new RealNumber((rand()>>shift)-minus  +((double)(rand()>>18))/(8191.0)));
        }; // generates a random number within boarders given

    public:
        static inline FormulaElement& getRandomRealOperation() {
            switch(rand()%5) { // 0 to 4 including boarders (inc. 0,4) :)
                case 0:
                    return *(new RealPlus());
                case 1:
                    return *(new RealMinus());
                case 2:
                    return *(new RealMultiplication());
                case 3:
                    return *(new RealDivide());
                case 4:
                    return *(new RealPow());
                default: {
                    assert(false);
                    return *(new RealPlus());
                }
            }
        }; // generates a random operation (no variables!)

        static inline FormulaElement& getRandomRealNumberOrVariable() {
            switch(rand()>>28) { // 0 to 7 with boarders
                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                    return FormulaFactoryUtil::getRealRandomNumber(25,31);
                case 6:
                case 7:
                    return *(new RealVariable('n',0));
                default: {
                    assert(false);
                    return *(new RealVariable('n',0));
                }
            }
        }; // generates a random Number or Variable


};

#endif // FORMULAFACTORYUTIL_H_INCLUDED
